# -*- coding: utf-8 -*-
# https://blog.csdn.net/weixin_52040868
# 公众号：测个der
# 微信：qing_an_an

import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtCore


class QWIN(QWidget):
    def __init__(self,parent=None):
        super(QWIN, self).__init__(parent)

        self.btn = QPushButton("OK", self)
        # 使用setObjectName设置对象名称
        self.btn.setObjectName("btn")

        layout = QHBoxLayout()
        layout.addWidget(self.btn)

        self.setLayout(layout)
        QtCore.QMetaObject.connectSlotsByName(self)
        # 信号与槽自动链接，如果自动连接则不需要装饰器
        # self.btn.clicked.connect(self.on_btn_clicked)

    @QtCore.pyqtSlot()
    def on_btn_clicked(self):   # 对象名需与上述保持一致
        print("单击了OK按钮")

if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = QWIN()
    win.show()
    app.exec_()
